package com.base.cn.platform.os.service.manage.user.login;

import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.manage.BaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 用户登录注册接口
 *
 * @author s.li
 * @create 2018-06-01-17:27
 */
@FeignClient(name = BaseService.appName,configuration = FeignAuthConfig.class)
public interface UserLoginService extends BaseService {

    /**
     * 强制学员退出登录
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/forceUserSignOut")
    Map<String,Object> forceUserSignOut(@RequestParam("userId") BigDecimal userId);

    /**
     * 验证找加密码的手机号
     * @param mobile 手机号
     * @param mobileCode 短信验证码
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/verificationForgetMobileCode")
    Map<String,Object> verificationForgetMobileCode(@RequestParam("mobile") String mobile,
                                                    @RequestParam("mobileCode") String mobileCode);
    /**
     * 重新缓存用户登录信息
     * @param sessionId 缓存KEY
     * @param userStr 用户对象
     */
    @RequestMapping(contextPath + "/user/updateUserLoginCache")
    void updateUserLoginCache(@RequestParam("sessionId") String sessionId,
                              @RequestParam("userStr") String userStr);

    /**
     * 学员登录
     * @param user    用户属性对象
     * @param client  登录终端（PC、MOBILE、APP）
     * @param autoThirty 30天自动登录
     * @param gapLeft 验证证图坐标
     * @param moveLeft 验证图移动坐标
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/userLogin")
    Map<String, Object> userLogin(@RequestBody Map<String, Object> user,
                                  @RequestParam("client") String client,
                                  @RequestParam("autoThirty") String autoThirty,
                                  @RequestParam(value = "gapLeft", required = false, defaultValue = "0") String gapLeft,
                                  @RequestParam(value = "moveLeft", required = false, defaultValue = "0") String moveLeft);

    /**
     * 注册用户
     * @param user 用户对象
     * @param loginForm 登录来源
     * @return
     */
    @RequestMapping(contextPath + "/user/toRegister")
    Map<String,Object> toRegister(@RequestBody Map<String, Object> user,
                                  @RequestParam("loginForm") String loginForm);
    /**
     * 设置学员专业
     * @param sessionId 用户缓存KEY
     * @param parentId 专业ID
     * @param childIds 科目ID串
     * @param autoThirty 缓存30天
     * @param loginForm 登录来源
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/setUserSubjectIds")
    Map<String,Object> setUserSubjectIds(@RequestParam("sessionId") String sessionId,
                                         @RequestParam("parentId") BigDecimal parentId,
                                         @RequestParam("childIds") String childIds,
                                         @RequestParam("autoThirty") String autoThirty,
                                         @RequestParam("loginForm") String loginForm);

    /**
     * 完善资料，设置用户手机号
     * @param sessionId 用户缓存KEY
     * @param mobile 绑定的手机号
     * @param mobileCode 手机验证码
     * @param autoThirty 缓存30天
     * @param loginForm 登录来源
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/setUserMobile")
    Map<String,Object> setUserMobile(@RequestParam("sessionId") String sessionId,
                                     @RequestParam("mobile") String mobile,
                                     @RequestParam("mobileCode") String mobileCode,
                                     @RequestParam("autoThirty") String autoThirty,
                                     @RequestParam("loginForm") String loginForm);

    /**
     * 设置登录密码
     * @param userId 用户ID
     * @param userPassword 用户密码
     * @param confirmPassword 用户确认过密码
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/setPerfectPwd")
    Map<String,Object> setPerfectPwd(@RequestParam("userId") BigDecimal userId,
                                     @RequestParam("userPassword") String userPassword,
                                     @RequestParam("confirmPassword") String confirmPassword,
                                     @RequestParam("sign") String sign);

    /**
     * 密码找回重置
     * @param mobile 手机号
     * @param mobileCode 手机验证码
     * @param password 密码
     * @param confirmPwd 确认密码
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/retrievePwd")
    Map<String,Object> retrievePwd(@RequestParam("mobile") String mobile,
                                   @RequestParam("mobileCode") String mobileCode,
                                   @RequestParam("password") String password,
                                   @RequestParam("confirmPwd") String confirmPwd,
                                   @RequestParam("sign") String sign);

    /**
     * 退出登录
     * @param sessionId 会话ID
     * @param userId 用户ID
     * @return true退出成功，false退出失败
     */
    @RequestMapping(contextPath + "/user/signOut")
    boolean signOut(@RequestParam("sessionId") String sessionId,
                    @RequestParam("userId") BigDecimal userId);

    /**
     * 设置用户登录Token
     * @param userId 用户ID
     * @param sessionId 用户登录Token
     */
    @RequestMapping(contextPath + "/user/setUserToken")
    void setUserToken(@RequestParam("userId") BigDecimal userId, @RequestParam("sessionId") String sessionId);

}
